import java.util.Scanner;

public class Solution {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            String[] s = sc.nextLine().trim().split(" ");
            int[] arr = new int[s.length];
            for (int i = 0; i < s.length; i++) {
                arr[i] = Integer.parseInt(s[i]);
            }
            System.out.println(jump(arr));
        }
    }
    /*这个题有许多地方需要注意一下：
    * 1.边界条件一定要找对dp[0]
    * 2.默认初始化的dp值为0，默认是最小的：需要判断dp==0需要另外处理②
    * 3.不要丢掉数组越界判断③
    * 4.初始值dp【0】==0需要另外处理④*/
    public static int jump(int[] nums) {
        int len = nums.length;
        int[] dp = new int[len];
        if (nums[0] == 0) {
            return 0;
        }

        for (int i = 0; i < len; i++) {
            if (i == 0/*④*/ || dp[i] != 0) {
                for (int j = 1; j <= nums[i]; j++) {
                    if (i + j < len/*③*/) {

                        if (dp[i + j] == 0 /*②*/|| dp[i + j] > dp[i] + 1) {
                            dp[i + j] = dp[i] + 1;
                        }
                    }
                }
            }
        }
        return dp[len-1];
    }
}
